$(document).ready(function() {
	loadPermission();
	function loadPermission() {
		alert("do");
		$.ajax( {
			type : "post",
			url : "admin/role_findAllPermission.action",
			success : showData
		});
	}
	$("#submit").click(function() {
		var roleName = $("#roleName").val();
		alert(roleName);
		$.ajax( {
			type : "post",
			data : "role.RName="+roleName,
			url : "admin/role_save.action"
		});
	});

	function showData(data) {
		$("#listEvent").empty();
		$("#listEvent").hide();
		$("#noneEvent").hide();
		$("#loadingEvent").hide();
		$.each(data.permissions, function(i, n) {
			fillDataToHtml(n.PId, n.PName);
		});
		$("#listEvent").show();

	}

	function fillDataToHtml(pid, pName) {
		var strHtml = "<tr>";
		strHtml += "<td ><div><input type='checkbox' /></div></td>";
		strHtml += "<td ><div>" + pName + "</div></td>";
		strHtml += "<td ><div><input type='checkbox' /></div></td>";
		strHtml += "<td ><div>" + pName + "</div></td>";
		strHtml += "</tr>";
		$("#listEvent").append(strHtml);
	}
});